#include  <iostream>
using namespace std;
#include <cstring>

/*
	构造函数： 用于对象初始化
		类中有有一个默认为空的构造函数
		函数名和类名相同,参数列表可以为空
		可以存在多个构造函数, 但是必须保证参数列表的不同（个数，顺序，类型）	
*/

class Student{
private:
	int 	id;
	char	name[20];
	bool 	isMale;
public:
	//默认构造函数
	Student(){ cout << "Student()" << endl; }

	Student(int _id, const char* _name, bool _isMale);
	Student(int _id) :id(_id) { cout << "Student(int)" << endl; }
	Student(int _id, bool _isMale):id(_id), isMale(_isMale){  cout << "Student(int, bool)" << endl; }
	Student(bool _isMale, int _id) :id(_id), isMale(_isMale) { cout << "Student(bool, int)" << endl; } 
	Student(const char* _name){ strcpy(name, _name);  cout << "Student(const char*)" << endl; }

	void instroduce();

	void setId(int _id) { id = _id; }
	void setName(const char* _name) { strcpy(name, _name); }
	void setIsMale(bool _isMale) { isMale = _isMale; }
};

Student::Student(int _id, const char* _name, bool _isMale)
	:id(_id),
	isMale(_isMale)				//列表初始化只适用用可以直接赋值的数据类型
{
	//id  = _id;
	strcpy(name, _name);
	//isMale = _isMale;
	cout << "Student(int, const char*, bool)" << endl;
}

void Student::instroduce()
{
	cout << "id: " << id << endl;
	cout << "name: " << name << endl;
	cout << "isMale: " << isMale << endl;
}


class Ex{
private:
	Ex(){}
};

int main(int argc, char **argv)
{
	Ex e;
	
	//在空间申请时，内存中的值
	Student tom;
	//Student jack = Student(2, "jack", false);
	Student jack(2, "jack", false);
	tom.setId(1);
	tom.setName("tom");
	tom.setIsMale(true);

	Student jozy(3);

	Student john(3, true);
	Student tony(false, 4);
	Student bob("bob");

	tom.instroduce();
	jack.instroduce();
	

	return 0;
}

